﻿using System;
using System.Data;
using System.Web.UI.WebControls;
using ASPNETVN.PORTAL.Components.Helpers;
using ASPNETVN.PORTAL.Components.Security;
using ASPNETVN.PORTAL.Components.UI;
using ASPNETVN.PORTAL.Modules.POLL.Components;
using ASPNETVN.PORTAL.Components.Share;


namespace ASPNETVN.PORTAL.Modules.POLL.Controls
{
    public partial class Result : ModulePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            BindData();
        }

        public void BindData()
        {
            DataTable dt;
            if (this.ItemID != 0)
            {
                dt = Answer.SelectResultBy_QuestionID(this.ItemID).Tables[0];
            }
            else
            {
                dt = Answer.SelectBy_ModuleID_Status(this.ModuleID, true).Tables[0];
            }
            if (dt.Rows.Count > 0)
            {
                lblResult.Text = dt.Rows[0]["Q_Des"].ToString();
                gvResult.DataSource = dt;
                gvResult.DataBind();
            }
            else
            {
                Components.Question question = Question.Load(this.ItemID);
                lblResult.Text = question.Description;
                lblNote.Text = "Không có kết quả trả lời";
            }
        }
    }
}